package com.example.springmvcproject.Service;

import cn.dev33.satoken.stp.StpInterface;
import com.example.springmvcproject.Mapper.RoleMapper;
import com.example.springmvcproject.Mapper.UserMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
@Log4j2
public class StpInterfaceImpl  implements StpInterface {

    @Resource
    UserMapper userMapper;

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return null;
    }

    /**
     * 返回一个账号所拥有的角色标识集合
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        log.info(Arrays.toString(new Object[]{loginId,loginType}));
        // 本list仅做模拟，实际项目中要根据具体业务逻辑来查询角色
        List<String> roles=new ArrayList<>();
        roles.add(String.valueOf(userMapper.selectRoleIdByLoginId(Integer.valueOf((String) loginId))));
        return roles;
    }

}
